(function(){

i=
{
	init:function()
	{
		i.loadMainJS(function(){

			if(typeof(_show_qrcode) == 'undefined')
			{
				console.log(location.href);
				var topbar=$("<div>");
				topbar.css({"width":document.body.clientWidth+"px","height":"300px","position":"relative","background-color":"0xffffff","z-index":"10000"});
				topbar.attr("id","topbar_qrcode");
				var qrbar = $("<div>");
				qrbar.css({"width":"300px","height":"300px","margin-left":"auto","margin-right":"auto","margin-top":"0px","margin-bottom":"0px","padding-top":"20px","padding-bottom":"20px","background-color":"0xffffff"});
				topbar.append(qrbar);
			
				qrbar.qrcode(location.href);
				topbar.hide();
				topbar.slideDown();
				$("body").prepend(topbar);
				_show_qrcode =1;
			}

			

		});
		
	},
	loadJS:function(c,b)
	{
		b=b||function(){};
		var a=document.createElement("script");
		a.type="text/javascript";
		a.setAttribute("cf_type","js");
		a.setAttribute("charset","utf-8");
		a.src=c;
		a.charset="utf-8";
		document.getElementsByTagName("head")[0].appendChild(a);
		if(a.readyState){
			if(a.complete){
				b();
			}else{
				a.onreadystatechange=function(){
					if(a.readyState=="complete"||a.readyState=="loaded"){
							b();
					}
				}
			}
		}else{
			a.onload=function(){
				b();
			}
		}
		a.onerror=function(){
		alert(c+" -- Load fail. 加载失败")}
	},

	loadCSS:function(v,a)
	{
		a=a||false;
		var b=v;
		if(a){
			b+="?t="+new Date().getTime();
		}
			var w=document.createElement("link");
			w.rel="stylesheet";
			w.type="text/css";
			w.setAttribute("cf_type","css");
			w.setAttribute("charset","utf-8");
			w.href=b;
			document.getElementsByTagName("head")[0].appendChild(w)
	},

	loadImg:function(c,b)
	{
		var a=new Image();
		a.src=c;
		if(a.readyState){
			if(a.complete){
				b(a);
			}else{
				a.onreadystatechange=function(){
					if(a.readyState=="complete"||a.readyState=="loaded"){
						b(a);
					}
				};
			}
		}else{
			a.onload=function(){
				b(a);
			}
		}
	},

	loadMainJS:function(b){
		i.loadJS(i.jsdata["jquery"],function()
		{
			i.loadJS(i.jsdata["qrcode"],b);
		})
	},

	jsdata:{"jquery":"https://git.oschina.net/cpplu11/qrcodeHtml/raw/master/jquery.min.js",
	"qrcode":"https://git.oschina.net/cpplu11/qrcodeHtml/raw/master/jquery.qrcode.min.js"},
}

i.init();

})();